import React, {Component, useEffect, useLayoutEffect, useState} from 'react';
import {Redirect, Route, Switch} from 'react-router-dom'
import {Row, Col, Affix, message} from 'antd';
import List from '../../components/List/List';
import styles from './index.module.css';
import MyInput from '../../components/searchInput/input';
import {get} from "../../utils/get";
import IndexMainHeader from "../../components/indexMain/indexMainHeader/indexMainHeader";
import TweetsList from "../../components/indexMain/tweetsList";
import LastList from "../../components/recommendList/lastList";
import LikeList from "../../components/recommendList/likeList";
import SearchList from "../../components/search/search";
import Favor from "../../components/favor";
import User from "../../components/user";
import TweetDetail from "../../components/indexMain/tweetDetail";
import {IndexMain} from "../../components/indexMain";
import {VisitMain} from "../../components/visitMain";

export default function Visit (props) {
    // const[data,changeData]=useState([])
    useLayoutEffect(()=>{
        if(localStorage.getItem('TOKEN'))
            props.history.replace('/index')
    })
        return (
            <div className={styles.content}>
                <div className={styles.row}>
                    <Row >
                        <Col span={7}>
                            <MyInput isRadius={true} delay={1000} size={5}></MyInput>
                            {/* 需要传 isRadius delay防抖时间 */}
                            <Affix offsetTop={45}>
                                <div>
                                    <LikeList/>
                                    <LastList/>
                                </div>
                            </Affix>
                        </Col>
                        <Col span={12} >
                            <Switch>
                                <Route exact path={"/visit/search"} component={SearchList}></Route>
                                <Route exact path={"/visit/detail/:shareId"} component={TweetDetail}></Route>
                                <Route exact path={"/"} component={VisitMain}></Route>
                                <Redirect to={"/"} component={VisitMain}></Redirect>
                            </Switch>
                        </Col>
                        <Col span={5} ><List /></Col>
                    </Row>
                </div>
            </div>
        )
}
